package ru.stepanovdn.trading.server.entity

import jakarta.persistence.*
import java.math.BigDecimal
import java.time.OffsetDateTime

@Entity
@Table(
    name = "candle",
    indexes = [Index(columnList = "figi"), Index(columnList = "date_time"), Index(columnList = "interval"), Index(
        columnList = "date_time, figi, interval",
        unique = true
    )]
)
data class Candle(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long? = null,

    @Column(name = "figi", nullable = false)
    var figi: String? = null,

    @Column(name = "highest_price", nullable = false, scale = 8, precision = 19)
    var highestPrice: BigDecimal? = null,

    @Column(name = "lowest_price", nullable = false, scale = 8, precision = 19)
    var lowestPrice: BigDecimal? = null,

    @Column(name = "open_orice", nullable = false, scale = 8, precision = 19)
    var openPrice: BigDecimal? = null,

    @Column(name = "closing_price", nullable = false, scale = 8, precision = 19)
    var closingPrice: BigDecimal? = null,

    @Column(name = "date_time", nullable = false)
    var dateTime: OffsetDateTime? = null,

    @Column(name = "interval", nullable = false)
    var interval: String? = null,

    @Version
    val version: Int? = null
)
